{{define "book/form.html"}}
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">书名</label>
            <div class="layui-input-block">
                <input type="text" name="Name" autocomplete="off" class="layui-input" value="{{.Name}}" required>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">编号</label>
            <div class="layui-input-block">
                <input type="text" name="CustomID" autocomplete="off" class="layui-input" value="{{.CustomID}}"
                       required>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">书号</label>
            <div class="layui-input-block">
                <input type="text" name="BookNo" autocomplete="off" class="layui-input" value="{{.BookNo}}" required>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">印刷颜色</label>
            <div class="layui-input-inline">
                <select name="PrintingColor" lay-verify="required">
                    {{$c := 0}}
                    {{if .}}
                        {{$c = .PrintingColor}}
                    {{end}}
                    <option value="1" {{if eq $c 1}}selected{{end}}>黑白</option>
                    <option value="2" {{if eq $c 2}}selected{{end}}>双色</option>
                    <option value="3" {{if eq $c 3}}selected{{end}}>四色</option>
                </select>
            </div>
        </div>

    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">分社</label>
            <div class="layui-input-block">
                <input type="text" name="FenShe" autocomplete="off" class="layui-input" value="{{.FenShe}}" required>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">项目</label>
            <div class="layui-input-inline">
                <select name="Project" lay-verify="required">
                    {{$p := 0}}
                    {{if .}}
                        {{$p = .Project}}
                    {{end}}
                    <option value="1" {{if eq $p 1}}selected{{end}}>正文</option>
                    <option value="2" {{if eq $p 2}}selected{{end}}>封面</option>
                    <option value="3" {{if eq $p 3}}selected{{end}}>重印书</option>
                </select>
            </div>
        </div>


    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">总页数</label>
            <div class="layui-input-block">
                <input type="text" name="PageCount" autocomplete="off" class="layui-input" value="{{.PageCount}}"
                       required>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">开本</label>
            <div class="layui-input-inline">
                <select name="KaiBen" lay-verify="required">
                    {{$k := ""}}
                    {{if .}}
                        {{$k = .KaiBen}}
                    {{end}}
                    <option value="B5" {{if eq $k "B5"}}selected{{end}}>B5</option>
                    <option value="16K" {{if eq $k "16K"}}selected{{end}}>16K</option>
                    <option value="大16K" {{if eq $k "大16K"}}selected{{end}}>大16K</option>
                    <option value="A4" {{if eq $k "A4"}}selected{{end}}>A4</option>
                    <option value="A5" {{if eq $k "A5"}}selected{{end}}>A5</option>
                    <option value="32K" {{if eq $k "32K"}}selected{{end}}>32K</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">版次</label>
            <div class="layui-input-block">
                <input type="text" name="Version" autocomplete="off" class="layui-input" value="{{.Version}}" required>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">修图</label>
            <div class="layui-input-inline">
                <select name="EditPic" lay-verify="required">
                    {{$e := 0}}
                    {{if .}}
                        {{$e = .EditPic}}
                    {{end}}
                    <option value="1" {{if eq $e 1}}selected{{end}}>在修</option>
                    <option value="2" {{if eq $e 2}}selected{{end}}>完成</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">照片图</label>
            <div class="layui-input-block">
                <input type="text" name="PicCount" autocomplete="off" class="layui-input" value="{{.PicCount}}"
                       required>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">重画图</label>
            <div class="layui-input-block">
                <input type="text" name="ChongHuaTu" autocomplete="off" class="layui-input" value="{{.ChongHuaTu}}"
                       required>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">可编辑图</label>
            <div class="layui-input-block">
                <input type="text" name="EditAblePicCount" autocomplete="off" class="layui-input"
                       value="{{.EditAblePicCount}}" required>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">难画图</label>
            <div class="layui-input-block">
                <input type="text" name="NaHuaTu" autocomplete="off" class="layui-input" value="{{.NaHuaTu}}" required>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <!--杜老板要求修改成这样-->
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <input type="text" name="CaiCha" autocomplete="off" class="layui-input" value="{{.CaiCha}}" required>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">选题号</label>
            <div class="layui-input-block">
                <input type="text" name="XuanTiHao" autocomplete="off" class="layui-input" value="{{.XuanTiHao}}"
                       required>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">责任编辑</label>
            <div class="layui-input-block">
                <input type="text" name="Editor" autocomplete="off" class="layui-input" value="{{.Editor}}" required>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">软件类型</label>
            <div class="layui-input-inline">
                <select name="SoftType" lay-verify="required">
                    {{$s := 0}}
                    {{if .}}
                        {{$s = .SoftType}}
                    {{end}}
                    <option value="1" {{if eq $s 1}}selected{{end}}>word</option>
                    <option value="2" {{if eq $s 2}}selected{{end}}>ID</option>
                    <option value="3" {{if eq $s 3}}selected{{end}}>方正</option>
                    <option value="4" {{if eq $s 4}}selected{{end}}>latex</option>
                </select>
            </div>
        </div>

    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">文案</label>
            <div class="layui-input-block">
                <input type="text" name="WenAn" autocomplete="off" class="layui-input" value="{{.WenAn}}" required>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">排版员</label>
            <div class="layui-input-block">
                <input type="text" name="PanBanYuan" autocomplete="off" class="layui-input" value="{{.PanBanYuan}}"
                       required>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">画图员</label>
            <div class="layui-input-block">
                <input type="text" name="HuaTuYuan" autocomplete="off" class="layui-input" value="{{.HuaTuYuan}}"
                       required>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">校对员</label>
            <div class="layui-input-block">
                <input type="text" name="JiaoDuiYuan" autocomplete="off" class="layui-input" value="{{.JiaoDuiYuan}}"
                       required>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">质量监控</label>
            <div class="layui-input-block">
                <input type="text" name="ZhiLianJiKong" autocomplete="off" class="layui-input"
                       value="{{.ZhiLianJiKong}}" required>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">加价</label>
            <div class="layui-input-block">
                <input type="text" name="PlusPrice" autocomplete="off" class="layui-input" value="{{.PlusPrice}}"
                       required>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <!--杜老板要求修改成这样-->
            <label class="layui-form-label">说明</label>
            <div class="layui-input-block">
                <input type="text" name="Remark" autocomplete="off" class="layui-input" value="{{.Remark}}" required>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn" lay-submit="" lay-filter="demo1" onclick="submitForm()">立即提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
    <script>
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;

            //日期
            laydate.render({
                elem: '#date'
            });
            laydate.render({
                elem: '#date1'
            });

            //创建一个编辑器
            var editIndex = layedit.build('LAY_demo_editor');

            //自定义验证规则
            form.verify({
                title: function (value) {
                    if (value.length < 5) {
                        return '标题至少得5个字符啊';
                    }
                }
                , pass: [
                    /^[\S]{6,12}$/
                    , '密码必须6到12位，且不能出现空格'
                ]
                , content: function (value) {
                    layedit.sync(editIndex);
                }
            });

            //监听指定开关
            form.on('switch(switchTest)', function (data) {
                layer.msg('开关checked：' + (this.checked ? 'true' : 'false'), {
                    offset: '6px'
                });
                layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
            });

            //监听提交
            /*form.on('submit(demo1)', function (data) {
                layer.alert(JSON.stringify(data.field), {
                    title: '最终的提交信息'
                });
            });*/

            //表单赋值
            layui.$('#LAY-component-form-setval').on('click', function () {
                form.val('example', {
                    "username": "贤心" // "name": "value"
                    , "password": "123456"
                    , "interest": 1
                    , "like[write]": true //复选框选中状态
                    , "close": true //开关状态
                    , "sex": "女"
                    , "desc": "我爱 layui"
                });
            });

            //表单取值
            layui.$('#LAY-component-form-getval').on('click', function () {
                var data = form.val('example');
                alert(JSON.stringify(data));
            });

        });

        function submitForm() {
            let id = $("#ID").val();
            let url = "/book/edit";
            if (id === undefined) {
                url = "/book/create";
            }
            $.post(url, $("#bookForm").serialize(), function (data) {
                if (data == "ok") {
                    layer.alert('操作成功', {icon: 1});
                }
            });
        }
    </script>

{{end}}